<extend name="Public/base"/>

<block name="body">
    <div class="main-title">
        <h2>新增/编辑码头</h2>
    </div>
    <form action="" method="post" class="form-horizontal">
        <input type="hidden" name="id" id="id" value="{$data['dock_id']}">
        <div class="form-item">
            <label class="item-label">所属港口<span class="check-tips"></span></label>
            <div class="controls">
                <select name="port_id" id="js-port">
                    <option value="0" >请选择港口</option>
                    <notempty name="plist">
                        <volist name="plist" id="vo">
                            <option value ="{$vo.port_id}" <?php if($data['port_id']==$vo['port_id']){ echo 'selected';} ?>>{$vo.port_name}</option>
                        </volist>
                    </notempty>
                </select> 
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">所属码头<span class="check-tips"></span></label>
            <div class="controls">
                <select name="dock_id" id="js-dock">
                    <option value="0" >请选择码头</option>

                    <notempty name="dlist">
                        <volist name="dlist" id="vo">
                            <option value ="{$vo.dock_id}" <?php if($data['dock_id']==$vo['dock_id']){ echo 'selected';} ?>>{$vo.dock_name}</option>
                        </volist>
                    </notempty>

                </select> 
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">堆场名称</label>
            <div class="controls">
                <input type="text" class="text input-large" name="yard_name" value="{$data['yard_name']}" placeholder="请填写堆场名称">
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">加价费用</label>
            <div class="controls">
                <input type="text" class="text input-large" name="yard_price" value="{$data['yard_price']}" placeholder="例如100">
            </div>
        </div>

        <div class="form-item">
            <button class="btn submit-btn ajax-post" id="submit" type="submit" target-form="form-horizontal">确 定</button>
            <button class="btn btn-return" onclick="javascript:history.back(-1); return false;">返 回</button>
        </div>
    </form>
</block>

<block name="script">
    <script type="text/javascript">
        $("#js-port").change(function () {
            var id = $(this).val();
            $.post("{:U('getDockByPortId')}", {id: id}, function (res) {
                if (res.status) {
                    var option = '';
                    $.each(res.url, function (index, obj) {
                        option += "<option value=\"" + obj.dock_id + "\">" + obj.dock_name + "</option>";
                    });
                    $("#js-dock").html(option);
                }
            });
        });
        //导航高亮
        highlight_subnav('{:U('Yard / index')}');
    </script>
</block>
